package com.ailanyin.admin.controller;

import com.ailanyin.admin.service.ExceptionLogService;
import com.ailanyin.common.result.AjaxResult;
import com.ailanyin.common.result.CommonPage;
import com.ailanyin.model.ExceptionLog;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2021/11/2 0002 下午 17:22
 */
@RestController
@RequestMapping("/system/exception")
@Api(tags = "后台异常信息管理")
public class ExceptionLogController {

    @Autowired
    private ExceptionLogService exceptionLogService;

    @GetMapping("/list")
    @ApiOperation(value = "获取异常日志列表")
    public CommonPage list(ExceptionLog exceptionLog,
                           @RequestParam(value = "pageSize", defaultValue = "5") Integer pageSize,
                           @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        List<ExceptionLog> list = exceptionLogService.selectExceptionLog(exceptionLog);
        return CommonPage.restPage(list);
    }

    @DeleteMapping("/remove")
    @ApiOperation(value = "批量删除异常日志")
    public AjaxResult removeExceptionLog(@RequestBody List<String> logIds) {
        exceptionLogService.removeExceptionLog(logIds);
        return AjaxResult.success();
    }
}
